package com.jy.rhin.support.notification;

import com.jy.rhin.infra.exception.RhinAggrErrorType;
import com.jy.rhin.support.notification.client.NotificationClient;
import com.jy.rhin.support.util.Asserts;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description: 消息通知调用客户端工厂
 * @Author: lww
 * @Date: 2022/7/29 9:42
 */
@Component
public class NotificationCallFactory {

    @Resource
    Map<String, NotificationClient> map;

    /**
     * 获取对应的消息通知调用客户端实现类
     *
     * @param interactionType
     * @return
     */
    public NotificationClient getClient(String interactionType) {
        Asserts.isTrue(map.containsKey(interactionType), RhinAggrErrorType.MESSAGE_SEND_TYPE_IS_EXISTENT);
        return map.get(interactionType);
    }
}
